require 'rbosa'

class ItunesController < ApplicationController
  
  def index 
    @itunes = OSA.app('iTunes')
    @playlist = @itunes.current_playlist()
    @track = @itunes.current_track()
    
   
  end   
  
  def play
    itunes = OSA.app('iTunes')
    
    # Play Track
    itunes.play
    
    # Fade the volume.
    50.times { |i| itunes.sound_volume = i; sleep 0.05 } 
    
    redirect_to :action => 'index'
  end
  
  def pause
    itunes = OSA.app('iTunes')
    itunes.pause
    redirect_to :action => 'index'
  end
  
  def stop
    itunes = OSA.app('iTunes')
    itunes.stop
    redirect_to :action => 'index'
  end
  
  def slider
      @phrase = request.raw_post || request.query_string
      itunes = OSA.app('iTunes')
      itunes.sound_volume = @phrase.to_i
  end
  
  def get_sound
    itunes = OSA.app('iTunes')
    @sound = itunes.sound_volume
  end
  
  def mute
  end
  
  def select_playlist
    
  end
  
  
  
  
end
